package com.cci.kangdao.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.cci.kangdao.aop.annotation.NoDuplicateSubmission;
import com.cci.kangdao.dto.BaseResponse;
import com.cci.kangdao.service.OutRangeTService;

import lombok.extern.slf4j.Slf4j;

/**
 * 超距离服务controller
 *
 */
@RestController
@Slf4j
public class OutRangeTController {

	@Autowired
	private OutRangeTService outRangeTService;

	@NoDuplicateSubmission
	@RequestMapping("/submitOutRangeApply.aspx")
	public BaseResponse submitOutRangeApply(@RequestBody JSONObject param) throws Exception {
		try {
			if(null != param){
				log.info("传参为"+param.toString());
			}
			return outRangeTService.submitOutRangeApply(param);
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
			return BaseResponse.error("未知错误");
		}
	}

	@NoDuplicateSubmission
	@RequestMapping("/modifyOutRangeApply.aspx")
	public BaseResponse modifyOutRangeApply(@RequestBody JSONObject param) throws Exception {
		try {
			if(null != param){
				log.info("传参为"+param.toString());
			}
			return outRangeTService.modifyOutRangeApply(param);
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
			return BaseResponse.error("未知错误");
		}
	}

	@RequestMapping("/getOutRangeApplyList.aspx")
	public BaseResponse getOutRangeApplyList(@RequestBody JSONObject param) throws Exception {
		try {
			if(null != param){
				log.info("传参为"+param.toString());
			}
			return outRangeTService.getOutRangeApplyList(param);
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
			return BaseResponse.error("未知错误");
		}
	}

	@RequestMapping("/getOutRangeApplyMsg.aspx")
	public BaseResponse getOutRangeApplyMsg(@RequestParam Long outRangeId) throws Exception {
		try {
			return outRangeTService.getOutRangeApplyMsg(outRangeId);
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
			return BaseResponse.error("未知错误");
		}
	}

	@RequestMapping("/getOutRangeApplyProcess.aspx")
	public BaseResponse getOutRangeApplyProcess(@RequestParam Long outRangeId) throws Exception {
		try {
			return outRangeTService.getOutRangeApplyProcess(outRangeId);
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
			return BaseResponse.error("未知错误");
		}
	}

	@NoDuplicateSubmission
	@RequestMapping("/submitOutRangeApprove.aspx")
	public BaseResponse submitOutRangeApprove(@RequestBody JSONObject param, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		try {
			if(null != param){
				log.info("传参为"+param.toString());
			}
			return outRangeTService.submitOutRangeApprove(param, request, response);
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
			return BaseResponse.error("未知错误");
		}
	}
}
